
//rename();
//transPicture();
println("hello world");
void rename() {
//    renameAndTransMap = ["bg.png":"login_bg.png"];
    String prefix = "login_";
    String picDir = "/Users/wxz/Downloads/登陆启动页/登录页/android";

    new File(picDir).eachFileRecurse {
        File file ->
            String fileName = file.getName();
            if (!fileName.endsWith(".png")) {
                return;
            }
            String toName =  fileName ;
            if (!toName.startsWith(prefix)) {
                toName = prefix + fileName;//renameAndTransMap[fileName];
            }
            if (toName != null && toName.length() > 0) {
                ('mv ' + file.getAbsolutePath() +' '
                + (new File(file.getParentFile(), toName).getAbsolutePath())).execute()
                println "" +file.getAbsoluteFile() + " - >" + toName;
            }
    }
}

void transPicture() {
    boolean transAll = true;
    List<String> toTransList = ["splash_logo.png"];

    File picDir = new File("/Users/wxz/Downloads/登陆启动页/登录页/android");
    File destDir = new File("/Users/wxz/company/zhibo/zhibo_android/app/src/main/res");

    List<String> legalDirs = ["drawable-xhdpi", "drawable-xxhdpi"];
    picDir.eachFile {
        File subDir ->
            if (legalDirs.contains(subDir.getName())) {
                File destSubDir = new File(destDir, subDir.getName());
                if (!destSubDir.exists()) {
                    destSubDir.mkdirs();
                }
                subDir.eachFile {
                    File drawable ->
                        String drawableFileName = drawable.getName();
                        if (transAll || toTransList.contains(drawableFileName)) {
                            File destFileDrawable = new File(destSubDir, drawableFileName);
                            if (destFileDrawable.exists()) {
                                destFileDrawable.delete();
                                println "删除了旧文件: "+ destFileDrawable.getAbsolutePath();
                            }
                            ('cp ' + drawable.getAbsolutePath() + " "
                            + destFileDrawable.getAbsolutePath()).execute()
                            println "拷贝了:" + destFileDrawable.getAbsolutePath()
                        }
                }

            }
    }

}